import request from '@/utils/request'

// 获取贴子列表
export const getPostListAPI = (data) => {
    return request.get({
        url: '/admin/m/posts/page',
        data
    })
}

// 添加帖子
export const addPostAPI = (data) => {
    return request.post({
        url: '/admin/m/posts',
        data
    })
}
/**
 * 删除帖子的API调用函数。
 *
 *
 * @param ids 帖子的ID数组，用于指定要删除的帖子。
 * @param type ：1.帖子 2.视频
 * @returns 返回一个Promise，解析为请求的响应数据。
 */

export const delPostAPI = (ids: string[], type: number) => {
    return request.delete({
        url: `/admin/m/posts`,
        data: {
            ids,
            type
        }
    })
}

// 编辑帖子
export const editPostAPI = (data) => {
    return request.put({
        url: `/admin/m/posts`,
        data
    })
}

// 获取详情  /admin/m/posts/{id}
export const getPostDetailAPI = (id: string) => {
    return request.get({
        url: `/admin/m/posts/${id}`
    })
}

// 点赞  /admin/m/posts/{id}/like
export const likePostAPI = (id: string) => {
    return request.post({
        url: `/admin/m/posts/${id}/like`
    })
}

// 收藏 /admin/m/posts/{id}/collect
export const collectPostAPI = (id: string) => {
    return request.post({
        url: `/admin/m/posts/${id}/collect`
    })
}

// 分享  /admin/m/posts/{id}/share
export const sharePostAPI = (id: string) => {
    return request.post({
        url: `/admin/m/posts/${id}/share`
    })
}

// /admin/m/posts/{id}/comment/page
// 获取评论
export const getPostCommentListAPI = (data: any) => {
    return request.get({
        url: `/admin/m/comment/page`,
        data
    })
}

// /admin/m/posts/{id}/comment
// 添加评论
export const addPostCommentAPI = (data: any) => {
    return request.post({
        url: `/admin/m/comment`,
        data
    })
}
